package com.itheima.a05myset;

import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;
import java.util.function.Consumer;

public class A01_SetDemo1 {
    public static void main(String[] args) {
        Set<String> set=new HashSet<>();
        boolean s1=set.add("张三");
        boolean s2=set.add("张三");

//        System.out.println(s1);
//        System.out.println(s2);
//        System.out.println(set);

        set.add("李四");
        set.add("王五");

        Iterator<String> it=set.iterator();
        while(it.hasNext()){
            String s=it.next();
            System.out.println(s);
        }

        for (String s : set) {
            System.out.println(s);
        }

        set.forEach(new Consumer<String>() {
            @Override
            public void accept(String s) {
                System.out.println(s);
            }
        });
    }
}
